package leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ht
 * @create 2025-06-19 21:35
 * @desc
 **/
public class T1 {

    public int[] twoSum(int[] nums, int target) {
        int[] arr = new int[2];

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            map.put(num, i);
        }

        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if(map.get(num) != i && map.containsKey(9 - num)) {
                arr[0] = i;
                arr[1] = map.get(9 - num);
                break;
            }
        }
        return arr;
    }
}
